package alo.p6.work;

import alo.p6.BinaryTreeNode;

//判断是否存在路径和等于值
public class HasPathSum {
    boolean hasPathSum(BinaryTreeNode root,int sum){
        if (root==null) return sum==0;
        else {
            int subSum=sum-root.getData();
            return hasPathSum(root.getLeft(),subSum)||hasPathSum(root.getRight(),subSum);
        }
    }
}
